package com.ibiaoke.customer.dao;

import com.ibiaoke.common.base.BaseDao;
import com.ibiaoke.customer.entity.PtFightGroup;
import com.ibiaoke.customer.entity.PtFightGroupExample;
import com.ibiaoke.customer.mapper.PtFightGroupMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

@Repository
public class PtFlightGroupDao extends BaseDao<PtFightGroup,PtFightGroupExample,Integer,PtFightGroupMapper>{

    @Autowired
    private PtFightGroupMapper ptFightGroupMapper;

    @Override
    public PtFightGroupMapper getMapper() {
        return ptFightGroupMapper;
    }

    public  PtFightGroup savePtFightGroup(PtFightGroup ptFightGroup){
        ptFightGroupMapper.insert(ptFightGroup);
        return  ptFightGroup;
    }

    public List<PtFightGroup> fightGroup(Integer ptGoodsId, Integer kid) {
        PtFightGroupExample example = new PtFightGroupExample();
        example.createCriteria().andPtGoodsIdEqualTo(ptGoodsId).andPidEqualTo(kid);

        return ptFightGroupMapper.selectByExample(example);
    }

    public Integer updatePayTypeAndPayMoney(Integer id, Integer payType,Double payMoney){
        PtFightGroup PtFightGroup = new PtFightGroup();
        PtFightGroup.setPid(id);
        PtFightGroup.setPayType(payType);
        PtFightGroup.setPayMoneny(new BigDecimal(payMoney));
        return ptFightGroupMapper.updateByPrimaryKeySelective(PtFightGroup);
    }

    public Integer deleteFightGroup(Integer pid, Integer isDelete){
        PtFightGroup PtFightGroup = new PtFightGroup();
        PtFightGroup.setPid(pid);
        PtFightGroup.setStatus(isDelete);
        return ptFightGroupMapper.updateByPrimaryKeySelective(PtFightGroup);
    }
    public PtFightGroup getFightGroup(Integer pid){
        return selectByPrimaryKey(pid);
    }

    public List<PtFightGroup> getFightGroupByKid(Integer kid){
        PtFightGroupExample example = new PtFightGroupExample();
        example.createCriteria().andKidEqualTo(kid);
        return ptFightGroupMapper.selectByExample(example);
    }
}
